---
layout: "default"
title: "Operator: &-="
description: "Swift documentation for the '&-=' operator."
root: "/v4.2"
---

<code class="language-swift"> operator &amp;-= {
    associativity right
    precedence 
    assignment
}</code>

<h3>Declarations</h3>

<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-ampmnseq_-inout-self-rhs_-self">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-ampmnseq_-inout-self-rhs_-self">func &amp;-=(<wbr>_:<wbr> inout Self, rhs: Self)</a>
        
<div class="comment collapse" id="comment-func-ampmnseq_-inout-self-rhs_-self"><div class="p">
    <p>Subtracts the second value from the first and stores the difference in the
left-hand-side variable, discarding any overflow.</p>

<p>The masking subtraction assignment operator (<code>&amp;-=</code>) silently discards any
overflow that occurs during the operation. In the following example, the
difference of <code>10</code> and <code>21</code> is less than zero, the minimum representable
<code>UInt</code> value, so the result is the overflowed value:</p>

<pre><code class="language-swift">var x: Int8 = 21
x &amp;-= 10
// x == 11
var y: UInt8 = 10
y &amp;-= 21
// y == 245 (after overflow)</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A numeric value.
  <strong>rhs:</strong> The value to subtract from <code>lhs</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;-=(lhs: inout Self, rhs: Self)</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
